package cn.cupk.logsystem.log.factoryPattern;

import cn.cupk.logsystem.log.observerPattern.Handler;
import cn.cupk.logsystem.log.LogRecord;

public class ConsoleHandler extends Handler {
    @Override
    public void publish(LogRecord record) {
        if (getFormatter() != null) {
            System.out.println(getFormatter().format(record));
        } else {
            System.out.println(record.getMessage());
        }
    }

    @Override
    public void flush() {
        // Console does not require flush.
    }

    @Override
    public void close() throws SecurityException {
        // Console does not require close.
    }
}
